package AppConf

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql Mysql
	Redis Redis
}
type Mysql struct {
	User     string
	Password string
	Host     string
	Port     string
	Database string
}
type Redis struct {
	Password string
	Host     string
	Port     string
}

var AppConf AppConfig

func ConfInit() {
	viper.SetConfigFile("../AppConf/conf.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println(1)
		fmt.Println(err)
		return
	}
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		fmt.Println(2)
		fmt.Println(err)
		return
	}
	fmt.Println(AppConf)
}
